package com.rainbow.common

import org.springframework.core.convert.converter.Converter
import java.text.ParseException
import java.text.SimpleDateFormat
import java.util.*

class DateConverter:Converter<String,Date> {

    private val simpleDateFormat:SimpleDateFormat= SimpleDateFormat("yyyy-MM-dd");

    override fun convert(p0: String): Date? {

        if ("" == p0) {
            return null
        }
        try {
            return simpleDateFormat.parse(p0)
        }catch (e:ParseException) {
            e.printStackTrace()
        }
        return null;
    }
}